package com.huantai.auth.controller;

import com.huantai.common.controller.BaseRestController;
import com.huantai.common.dto.BaseResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @author zhangpeipei
 * @date 2020/5/9 15:51
 */
@Api(tags = "Demo RESTFUL APIs")
@RestController
@Slf4j
public class HelloController extends BaseRestController {

    @Autowired
    RestTemplate restTemplate;

    @GetMapping(value = "/hello")
    public BaseResponse hello() {

        String res = restTemplate.getForObject("http://customer-service/hello", String.class);
        log.info(res);

        return succResponse(res);
    }

    @PostMapping(value = "/hello2")
    public BaseResponse hello2() {

        String res = restTemplate.postForObject("http://customer-service/hello2", null, String.class);
        log.info(res);

        return succResponse("hello2");
    }

}
